using ChikovMF.Application.Features.Projects.DeleteProject;
using Microsoft.EntityFrameworkCore;

namespace ChikovMF.Tests.Projects.Commands;

public class DeleteProjectTest : TestCommandBase
{
    [Fact]
    public async Task DeleteProjectTest_Success()
    {
        var handler = new DeleteProjectCommandHandler(_context);
        var command = new DeleteProjectCommand
        {
            ProjectId = new Guid("e6e7d3f0-b9b9-4f0b-a9b9-fe0b584bb9cd")
        };
        var oldProject = await _context.Projects.FirstOrDefaultAsync(project => project.ProjectId == command.ProjectId);

        await handler.Handle(
            command,
            CancellationToken.None
        );

        Assert.NotNull(oldProject);
        Assert.Null(await _context.Projects.FirstOrDefaultAsync(project => project.ProjectId == command.ProjectId));
    }
}